package yhp.com.zijie.web;


import yhp.com.zijie.bean.Grade;
import yhp.com.zijie.bean.Student;
import yhp.com.zijie.service.GradeService;
import yhp.com.zijie.service.StudentService;
import yhp.com.zijie.service.impl.GradeServiceImpl;
import yhp.com.zijie.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/Educational/student/findById")
public class FindByIdStudentServlet extends HttpServlet {


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String stuId = req.getParameter("stuId");
        System.out.println(stuId);
        System.out.println(".....................................");

        StudentService studentService = new StudentServiceImpl();
        //查询学生信息
        Student student = studentService.findById(Integer.parseInt(stuId));

        //
        GradeService gradeService = new GradeServiceImpl();
        List<Grade> gradeList = gradeService.showGrade();

        req.setAttribute("stu", student);
        req.setAttribute("grade" , gradeList);

        //跳转页面
        req.getRequestDispatcher("edit.jsp").forward(req , resp);

    }
}
